package com.moyun.finance.controller;

import com.moyun.finance.entity.Account;
import com.moyun.finance.entity.Response;
import com.moyun.finance.entity.TypeMenu;
import com.moyun.finance.service.AccountService;
import com.moyun.finance.service.TypeMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/typeMenu")
public class TypeMenuController {
    @Autowired
    TypeMenuService tms;

    //类别列表新增
    @RequestMapping("/save")
    public @ResponseBody Response save(@RequestBody TypeMenu typeMenu){
        Response res = tms.save(typeMenu);
        return res;
    }

    //类别列表修改
    @RequestMapping("/update")
    public @ResponseBody Response update(@RequestBody TypeMenu typeMenu){
        Response res = tms.update(typeMenu);
        return res;
    }

    //类别列表删除
    @RequestMapping("/delete")
    public @ResponseBody Response delete(@RequestBody TypeMenu typeMenu){
        Response res = tms.delete(typeMenu);
        return res;
    }

    //查询指定公司所有类别
    @RequestMapping("/findTree")
    public @ResponseBody Response findTree(String companyId, int type){
        List<TypeMenu> typeMenus = tms.findTree(companyId, type);
        return new Response("",typeMenus,true);
    }

    //根据id查类别
    @RequestMapping("/findById")
    public @ResponseBody Response findOneById(String typeMenuId){
        TypeMenu tm = tms.findOneById(typeMenuId);
        return new Response("",tm,true);
    }
}
